package com.wg.springbootwar.web;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;

/**
 * @Description:
 * @Author WuGang
 * @Date 2021/10/21 19:32
 * @Version 1.0
 */
@Controller
public class UserController {
    @RequestMapping("/userdetail")
    public @ResponseBody
    Object say() {
        HashMap<String, Object> map = new HashMap<>();
        map.put("id", 1001);
        map.put("name", "张三");
        return map;
    }

    @RequestMapping("/page/user")
//     @ResponseBody  加了返回的就是字符串JSON
    public  String say1(Model model) {
        model.addAttribute("id", 1002);
        model.addAttribute("name", "张三");
        return "user";
    }
}
